/**
 * 
 */
package com.dsbridge.enrollment.jpadao;

import java.util.List;

import javax.persistence.EntityManagerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.stereotype.Repository;

import com.dsbridge.enrollment.entities.CourseAuthor;
import com.dsbridge.enrollment.entities.Subject;

/**
 * @author rithvik
 * 
 */
@Repository
public class SubjectsJPADAO {

	@Autowired
	private EntityManagerFactory emf;

	private JpaTemplate jpaTemplate;

	
	/**
	 * @param subject
	 * @return
	 */
	public int createSubject(Subject subject) {
		jpaTemplate = new JpaTemplate(emf);
		jpaTemplate.persist(subject);
		return subject.getSubjectId();
	}
	/**
	 * @return
	 */
	public List<Subject> retrieveAllAuthors(){
		jpaTemplate=new JpaTemplate(emf);
		List<Subject> list=jpaTemplate.find("from com.dsbridge.enrollment.entities.Subject");
		return list;
	}

}
